home *** CD-ROM | disk | FTP | other *** search
/ Merciful 4 / Merciful - Disc 4.iso / rexx / isopalette.pprx < prev    next >
Text File  |  1996-11-02  |  2KB  |  93 lines

  1. /* Personal Paint Amiga Rexx script - Copyright © 1995, 1996 Cloanto Italia srl */
  2.  
  3. /* $VER: IsoPalette.pprx 1.0 */
  4.  
  5. /** ENG
  6.   This script generates an iso-palette composed of equally-spaced colors
  7.   in the color cube (color mode) or a grayscale palette (gray mode).
  8. */
  9.  
  10. IF ARG(1, EXISTS) THEN
  11.     PARSE ARG PPPORT graymode
  12. ELSE DO
  13.     PPPORT = 'PPAINT'
  14.     graymode = 0
  15. END
  16.  
  17. IF ~SHOW('P', PPPORT) THEN DO
  18.     IF EXISTS('PPaint:PPaint') THEN DO
  19.         ADDRESS COMMAND 'Run >NIL: PPaint:PPaint'
  20.         DO 30 WHILE ~SHOW('P',PPPORT)
  21.              ADDRESS COMMAND 'Wait >NIL: 1 SEC'
  22.         END
  23.     END
  24.     ELSE DO
  25.         SAY "Personal Paint could not be loaded."
  26.         EXIT 10
  27.     END
  28. END
  29.  
  30. IF ~SHOW('P', PPPORT) THEN DO
  31.     SAY 'Personal Paint Rexx port could not be opened'
  32.     EXIT 10
  33. END
  34.  
  35. ADDRESS VALUE PPPORT
  36. OPTIONS RESULTS
  37. OPTIONS FAILAT 10000
  38.  
  39. LockGUI
  40.  
  41. /*         Entries  R G B  Clrs Grays  */
  42. /*         --------------------------  */
  43. colorset.0 = '256   7 7 5  245   11'
  44. colorset.1 = '128   5 6 4  120   8 '
  45. colorset.2 = '64    4 5 3   60   4 '
  46. colorset.3 = '32    3 3 3   27   5 '
  47. colorset.4 = '16    2 3 2   12   4 '
  48. colorset.5 = '8     2 2 2    8   0 '
  49.  
  50.  
  51. Get 'COLORS'
  52. cnum = RESULT
  53. DO set = 0 to 5
  54.     PARSE VAR colorset.set cn rbits gbits bbits . gnum .
  55.     IF cn = cnum THEN
  56.         LEAVE
  57. END
  58. IF set > 5 THEN
  59.     graymode = 1
  60.  
  61. palette = ''
  62. IF graymode = 0 THEN DO
  63.     rstep = 255 / (rbits - 1)
  64.     gstep = 255 / (gbits - 1)
  65.     bstep = 255 / (bbits - 1)
  66.  
  67.     DO red = 0 TO 255 BY rstep
  68.         DO green = 0 TO 255 BY gstep
  69.             DO blue = 0 TO 255 BY bstep
  70.                 palette = palette TRUNC(red + 0.5) TRUNC(green + 0.5) TRUNC(blue + 0.5)
  71.             END
  72.         END
  73.     END
  74.     IF gnum > 0 THEN DO
  75.         gstep = 255 / (gnum + 1)
  76.         DO gry = gstep TO 255-gstep BY gstep
  77.             igry = TRUNC(gry + 0.5)
  78.             palette = palette igry igry igry
  79.         END
  80.     END
  81. END
  82. ELSE DO
  83.     gstep = 255 / (cnum - 1)
  84.     DO gry = 0 TO 255 BY gstep
  85.         igry = TRUNC(gry + 0.5)
  86.         palette = palette igry igry igry
  87.     END
  88. END
  89.  
  90. SetColors 'COLORS "'palette'"'
  91.  
  92. UnlockGUI
  93.